package net.xiduth.game.player.dialogues.impl;

import java.text.NumberFormat;

import net.xiduth.DialAnims;
import net.xiduth.game.player.dialogues.Dialogue;

/**
 * 
 * @author Jae <jae@xiduth.com>
 * 
 * @since <Oct 18, 2013>
 *
 */
public class ExperienceLamp extends Dialogue {

	int exp, itemId;
	@Override
	public void start() {
		exp = (Integer) parameters[0];
		itemId = (Integer) parameters[1];
		sendOptionsDialogue("Do you wish to receive " + NumberFormat.getIntegerInstance().format(exp) + " experience?", "Yes", "No");
	}

	@Override
	public void run(int interfaceId, int option) {
		switch(stage) {
		case -1:
			switch(option) {
			case OPTION_1:
				sendPlayerDialogue(DialAnims.HAPPY_TALKING.getId(), "I should enter the name of the skill to receive experience in...");
				stage = 0;
				break;
			case OPTION_2:
				end();
				break;
			}
			break;
		case 0:
			if (player.getInventory().containsItem(itemId, 1)) {
				player.getAttributes().put("exp_lamp_item", itemId);
				player.getAttributes().put("experience_receiving", exp);
				player.getPackets().sendInputNameScript("Enter the name of the skill you want experience in (e.g strength)");
				end();
			} else {
				end();
				player.sendMessage("Nice try!");
			}
			break;
		}
	}

	@Override
	public void finish() {

	}

}
